﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"                
					xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
					xmlns:vi="http://schemas.rhea.be/vidyano/2007/presentation"
                    xmlns:markup="clr-namespace:RapidDownloader.Markup"
                    >

	<ResourceDictionary.MergedDictionaries>
		<ResourceDictionary Source="Theme\Controls.xaml" />
		<ResourceDictionary>
			<BooleanToVisibilityConverter x:Key="bToVis" />

			<DataTemplate x:Key="Vidyano.HeaderTemplate">
				<StackPanel DataContext="{vi:ServiceSource ServiceType=AuthenticatorService}" Orientation="Horizontal" Visibility="{Binding IsAuthenticated, Converter={StaticResource bToVis}}">
					<TextBlock Text="Rapids : " FontWeight="Bold" />
					<TextBlock Text="{Binding Rapids}" />

					<TextBlock Text="  |  " Foreground="LightGray" />

					<TextBlock Text="Valid until : " FontWeight="Bold" />
					<TextBlock Text="{Binding ValidUntil}" />
				</StackPanel>
			</DataTemplate>

			<Style TargetType="vi:Shell">
				<Setter Property="IsTabStop" Value="False" />
				<Setter Property="Focusable" Value="False" />
				<Setter Property="Template">
					<Setter.Value>
						<ControlTemplate TargetType="vi:Shell">
							<DockPanel>
								<DockPanel DockPanel.Dock="Top" Height="35" LastChildFill="False">
									<DockPanel.Background>
										<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
											<GradientStop Color="White"/>
											<GradientStop Color="Gainsboro" Offset="1"/>
										</LinearGradientBrush>
									</DockPanel.Background>

									<vi:Region x:Name="Menu" DockPanel.Dock="Left" />

									<ContentControl Content="{Binding Header, Source={x:Static Application.Current}}" ContentTemplate="{DynamicResource Vidyano.HeaderTemplate}" VerticalAlignment="Center" Margin="5,0,0,0" DockPanel.Dock="Left" />

									<vi:Region x:Name="Authenticator" DockPanel.Dock="Right" />
								</DockPanel>

								<Grid>
									<Grid.Background>
										<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
											<GradientStop Color="#FFD8D8D8" Offset="0"/>
											<GradientStop Color="#FFE5E5E5" Offset="1"/>
										</LinearGradientBrush>
									</Grid.Background>
									<Rectangle Height="8" VerticalAlignment="Top">
										<Rectangle.Fill>
											<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
												<GradientStop Color="#FF898989" Offset="0"/>
												<GradientStop Offset="1"/>
											</LinearGradientBrush>
										</Rectangle.Fill>
									</Rectangle>

									<vi:Region x:Name="Background" />
									<Grid>
										<Grid.RowDefinitions>
                                            <RowDefinition MaxHeight="{vi:AncestorBinding AncestorType=Grid, Path=ActualHeight, Converter={x:Static markup:RelativeConverter.Instance}, ConverterParameter=0.66}" />
											<RowDefinition MinHeight="300" MaxHeight="{vi:AncestorBinding AncestorType=Grid, Path=ActualHeight, Converter={x:Static markup:RelativeConverter.Instance}, ConverterParameter=0.34}" />
										</Grid.RowDefinitions>

										<vi:MultiRegion x:Name="Content" Margin="0,8,0,8" />

										<TabControl Grid.Row="1">
											<TabControl.Resources>
												<Style TargetType="TabItem">
													<Setter Property="Template">
														<Setter.Value>
															<ControlTemplate TargetType="TabItem">
																<Border x:Name="border" Background="WhiteSmoke" Padding="5">
																	<ContentPresenter ContentSource="Header" TextElement.FontWeight="Bold" TextElement.FontSize="16" HorizontalAlignment="Center" x:Name="content" />
																</Border>
																<ControlTemplate.Triggers>
																	<Trigger Property="IsSelected" Value="False">
																		<Setter Property="Background" TargetName="border" Value="#FFAAAAAA" />
																		<Setter Property="TextElement.Foreground" TargetName="content" Value="White" />
																		<Setter Property="TextElement.FontWeight" TargetName="content" Value="Normal" />
																	</Trigger>
																</ControlTemplate.Triggers>
															</ControlTemplate>
														</Setter.Value>
													</Setter>
												</Style>
											</TabControl.Resources>

											<TabControl.Template>
												<ControlTemplate TargetType="TabControl">
													<Grid ClipToBounds="true" KeyboardNavigation.TabNavigation="Local">
														<Grid.RowDefinitions>
															<RowDefinition x:Name="RowDefinition0" Height="Auto"/>
															<RowDefinition x:Name="RowDefinition1" Height="*"/>
														</Grid.RowDefinitions>
														<UniformGrid Rows="1" x:Name="HeaderPanel" Grid.Column="0" IsItemsHost="true" Grid.Row="0" KeyboardNavigation.TabIndex="1" Panel.ZIndex="1"/>
														<Border x:Name="ContentPanel" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" KeyboardNavigation.DirectionalNavigation="Contained" Grid.Row="1" KeyboardNavigation.TabIndex="2" KeyboardNavigation.TabNavigation="Local">
															<ContentPresenter x:Name="PART_SelectedContentHost" ContentSource="SelectedContent" Margin="{TemplateBinding Padding}" />
														</Border>
													</Grid>
												</ControlTemplate>
											</TabControl.Template>

											<TabItem Header="Download Queue">
												<vi:Region x:Name="DownloadQueue" />
											</TabItem>

											<TabItem Header="Extract Queue">
												<vi:Region x:Name="ExtractQueue" />
											</TabItem>
											
											<TabControl.Style>
												<Style TargetType="TabControl">
													<Setter Property="Visibility" Value="Visible" />
													<Style.Triggers>
														<MultiDataTrigger>
															<MultiDataTrigger.Conditions>
																<Condition Binding="{Binding CurrentModule, ElementName=DownloadQueue}" Value="{x:Null}" />
																<Condition Binding="{Binding CurrentModule, ElementName=ExtractQueue}" Value="{x:Null}" />
															</MultiDataTrigger.Conditions>

															<Setter Property="Visibility" Value="Hidden" />
														</MultiDataTrigger>
													</Style.Triggers>
												</Style>
											</TabControl.Style>
										</TabControl>
									</Grid>
									<vi:Region x:Name="Foreground" />
								</Grid>
							</DockPanel>
						</ControlTemplate>
					</Setter.Value>
				</Setter>
			</Style>
		</ResourceDictionary>
	</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>